package com.xmwzw.catpu.item;

import android.databinding.DataBindingUtil;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.bumptech.glide.Glide;
import com.mikepenz.fastadapter.items.AbstractItem;
import com.xmwzw.catpu.R;
import com.xmwzw.catpu.bean.SoftBean;
import com.xmwzw.catpu.databinding.ItemCollectionBinding;

import java.util.List;

/**
 * @author : wangzw
 * @date : 20-4-3下午5:23
 * @desc :
 */
public class CollectItem extends AbstractItem<CollectItem, CollectItem.ViewHolder> {
    @Override
    public ViewHolder getViewHolder(View v) {
        return new ViewHolder(v);
    }

    @Override
    public int getType() {
        return 0;
    }

    @Override
    public int getLayoutRes() {
        return R.layout.item_collection;
    }

    private SoftBean softBean;

    public CollectItem fillData(SoftBean softBean) {
        this.softBean = softBean;
        return this;
    }

    @Override
    public void bindView(ViewHolder holder, List<Object> payloads) {
        super.bindView(holder, payloads);

        Glide.with(holder.collectionBinding.ivLogo.getContext()).load(softBean.icon_url)
                .into(holder.collectionBinding.ivLogo);

    }

    public class ViewHolder extends RecyclerView.ViewHolder{
        private ItemCollectionBinding collectionBinding;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            collectionBinding = DataBindingUtil.bind(itemView);

        }
    }
}
